<template>
	<view class="root-box root-container root-page-top">
		<uv-navbar @leftClick="goBack" placeholder bgColor="transparent" :fixed="false" />
		<view class="content" v-if="agentInfo">
			<view class="header-box">
				<uv-avatar :src="userInfo.avatar || getIconPath('avatar.png')" size="60" />
				<view class="header-item">
					<view class="user-box">
						<uv-text :text="agentInfo.real_name" size="18" color="#333" bold style="padding-right: 10rpx;" />
						<view class="label-item">代理商</view>
					</view>
					<uv-text :text="'ID:'+agentInfo.id" size="14" color="#333" style="" />
				</view>
			</view>
			<view class="list-box">
				<uv-list>
					<uv-list-item title="收费标准"
						thumb="https://linshitong.oss-cn-shenzhen.aliyuncs.com/dev/image/2025/0816/4c66d202508161052045584.png"
						thumb-size="medium" link to="/pages-user/distributor/fee_schedule">
					</uv-list-item>

					<uv-list-item title="实名信息"
						thumb="https://linshitong.oss-cn-shenzhen.aliyuncs.com/dev/image/2025/0816/e38262025081610523413.png"
						thumb-size="medium" link to="/pages-user/distributor/real_information">
					</uv-list-item>

					<uv-list-item title="隐私政策"
						thumb="https://linshitong.oss-cn-shenzhen.aliyuncs.com/dev/image/2025/0816/7bdaf202508161052557298.png"
						thumb-size="medium" link to='/pages-user/distributor/privacy_policy?type=7&agreement_type=2'>
					</uv-list-item>

				</uv-list>
			</view>
		</view>
		<uv-tabbar :value="tabValue" @change="changePage(index)" activeColor="red">
			<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
			<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
		</uv-tabbar>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		useUserStore,
		useAgentStore
	} from '@/store'

	import {
		storeToRefs
	} from 'pinia'
	import {
		getIconPath
	} from '@/util'
	import {
		joinAgentDetail
	} from '@/api'
	
	import { useCustomBack } from '@/components/useCustomBack.js'

	const tabValue = ref(1)
	const agent = useAgentStore()
	const user = useUserStore()
	const {
		token,
		userInfo
	} = storeToRefs(user)
	const agentInfo = ref(null)
	
	const { goBack } = useCustomBack('/pages-user/select_Identity')

	const changePage = (index) => {
		
		if (tabValue.value == 1) {
			uni.navigateTo({
				url: '/pages-agent/home',
				success: function(res) {

				},
				fail: function(err) {

				}
			})

		}
	}
	const getAgentInfo = async () => {
		const result = await joinAgentDetail()
		if (result.code == 200) {
			agentInfo.value = result.result
			agent.setAgentData(agentInfo.value)
		}
	}
	const init = async () => {
        await getAgentInfo()
	}

	init()
</script>

<style lang="scss" scoped>
	.root-box {



		.content {
			padding: 30rpx;
			box-sizing: border-box;

		}

		.header-box {
			display: flex;
			align-items: center;
			margin-top: 30rpx;

			.header-item {
				margin-left: 20rpx;

				.user-box {
					display: flex;
					align-items: center;

					.label-item {

						background-color: red;
						border-radius: 15rpx 0 15rpx 0;
						padding: 4rpx 10rpx;
						box-sizing: border-box;
						color: #fff;
						font-size: 16rpx;
					}
				}

			}

		}

		.list-box {
			padding: 20rpx;
			box-sizing: border-box;
			margin-top: 60rpx;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			background-color: #fff;
			box-shadow: 5rpx 5rpx 5rpx #cccccc;

			:deep(.uvicon-arrow-right) {
				font-size: 24rpx !important;
			}
		}
	}
</style>